package practice06;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice06
 * @ClassName: People
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/17 20:14
 * @Copyright 大牛版板所有
 */
public class People {
    static Map<Integer,String> map = new HashMap<Integer, String>();

    static {
        map.put(1, "张三丰");
        map.put(2, "周芷若");
        map.put(3, "汪峰");
        map.put(4, "灭绝师太");
    }

    // 遍历map集合
    public static void showAll(){
        for (Map.Entry<Integer,String> en:map.entrySet()) {
            System.out.println("key="+en.getKey()+"， value="+en.getValue());
        }
    }


    public static void main(String[] args) {

        // 添加信息
        System.out.println("==============================================");
        map.put(5,"李晓红");
        showAll();

        // 删除信息
        System.out.println("==============================================");
        map.remove(1);
        showAll();

        // 替换
        System.out.println("==============================================");
        map.put(2,"周林");
        showAll();
    }
}
